package com.woniuxy.kaer.commons.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {
    private Integer code;
    private String message;
    private T data;
    private List<T> list;

    public static Result succeed(String message, Object data){
        Result<Object> result = new Result<>();
        result.setCode(200);
        result.setMessage(message);
        result.setData(data);
        return result;
    }
    public static Result success(String message, Object data, List<Object> list){
        Result<Object> result = new Result<>();
        result.setCode(200);
        result.setMessage(message);
        result.setData(data);
        result.setList(list);
        return result;
    }
    public static Result fail(Integer code, String message) {
        Result<Object> result = new Result<>();
        result.setCode(code);
        result.setMessage(message);
        return result;

    }
    public static Result auth(Integer code, String message) {
        Result<Object> result = new Result<>();
        result.setCode(code);
        result.setMessage(message);
        return result;
    }
}
